package com.liaogui.thread;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

/**
 * @author liaogui
 * @date 2025/1/17 15:23
 */
@Slf4j
public class CallableAndFutureTaskDemo implements Callable<Long> {
    public static void main(String[] args) throws Exception {
        CallableAndFutureTaskDemo callable = new CallableAndFutureTaskDemo();
        FutureTask<Long> task = new FutureTask<>(callable);
        new Thread(task).start();
        log.info("线程{}: 启动成功", callable.call());
    }

    @Override
    public Long call() throws Exception {
        return Thread.currentThread().getId();
    }
}
